package drawing;

import java.awt.*;

// Homework 11 written by Mladen Yakimov (GTID: 902575580)
// Collaboration Statement:
// I did not discuss this assignment with anyone.

/**
* @author Mladen Yakimov
* This is HW11
* This class is the Rectangle class, a subclass of MovableShape
*/
public class Rectangle extends MovableShape {

	private int deltaX;
	private int deltaY;
	private int maxX;
	private int maxY;

   /**
   * This is the rectangle constructor
   * @param x x-position
   * @param y y-position
   * @param width the radius of the rectangle
   * @param height the height of the shape
   * @param maxX the maximum width (size of window)
   * @param maxY the maxmum height (size of the window)
   * @param deltaX the change of x
   * @param deltaY the change of y
   */
	public Rectangle(int x, int y, int width, int height, int maxX, int maxY, int deltaX, int deltaY) {
		super(x,y,width,height);

		this.maxX = maxX;
		this.maxY = maxY;
		this.deltaX = deltaX;
		this.deltaY = deltaY;

	}
   /**
   * This is the move method for the Rectangle class
   * It moves the the rectangle by incrementing deltaX and deltaY
   */
	public void move() {

		x+=deltaX;
		y+=deltaY;

		if(x+width>=maxX)
			deltaX = -1*deltaX;

		if(x<=0)
			deltaX = -1*deltaX;

		if(y+height>=maxY)
			deltaY = -1*deltaY;

		if(y<=0)
			deltaY = -1*deltaY;
	}

   /**
   * This method draws the Rectangle
   * @param g the graphics object to draw the Rectangle
   */
	public void draw(Graphics g) {

		g.drawRect(x, y, width, height);

	}

}


